Security and Authentication

Dynamically Set the Start Page Based on Logged-In User

Description
This customization demonstrates how to set the start page of an application based on the identity of the logged-in user.
Variables
Applies to
SignIn class
Code
 
''' 
''' Performs the custom redirect after successful login
''' 
Protected Overrides Sub RedirectOnSuccess()
			If (Not String.IsNullOrEmpty(Me.SuccessURL)) Then
				Me.Page.Response.Redirect(Me.SuccessURL)
			Else
				Dim role As String = BaseClasses.Utils.SecurityControls.GetCurrentUserRoles()
		        
				' GetCurrentUserRoles() will return semi-colon-delimited list of RoleIDsvalues such as {RoleID1;RoleID2}.
				' Note, that for ActiveDirectory Security roles names are effectively roles IDs. Also note, that 
				' Active Directory and Azman roles can include domain name such as "MyDomain\RoleName".
				If role = "" Then
					CType(Me.Page, BaseApplicationPage).RedirectBack(False)
				End If
				Dim separator As Char() = {";"c}
				Dim roles As String() = role.Split(separator, System.StringSplitOptions.RemoveEmptyEntries)
				Dim includes As Boolean = False
				For Each r As String In  roles
					If r = "2" Then
						includes = True
					End If
				Next r
				If includes Then
				   Me.Page.Response.Redirect("../TableName/ShowTableNameTable.aspx")
				Else
					CType(Me.Page, BaseApplicationPage).RedirectBack(False)
				End If
			End If
End Sub
     

Terms of Service Privacy Statement